package com.nuoniu.sibanyun.mapper.crm;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.crm.CrmCode;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 编码设置 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-06-16
 */
@Mapper
@Component
public interface CrmCodeMapper extends BaseMapper<CrmCode> {

    /**
     * 获取编码设置列表
     * @author 小啊刚
     * @date 2020/6/16
     */
    @Select("select * from crm_code where company_id = #{companyId}")
    List<CrmCode> getCodeList(Integer companyId);

    /**
     * 批量插入
     * @author 小啊刚
     * @date 2020/6/18
     */
    @Insert("insert into crm_code (company_id, company_name, module_name, default_code, current_code, create_user_id, create_user_name, update_user_id, update_user_name) " +
            "select #{companyId}, #{companyName}, module_name, default_code, current_code, #{userId}, #{realName}, #{userId}, #{realName} from crm_code where company_id = 1")
    void saveAll(Integer companyId, String companyName, Integer userId, String realName);

    /**
     * 获取编码详情
     * @author 小啊刚
     * @date 2020/6/19
     */
    @Select("select * from crm_code where company_id = #{companyId} and module_name = #{moduleName}")
    CrmCode getCode(Integer companyId, String moduleName);
}
